package com.fs.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fs.mapper.WhDetailedMapper;
import com.fs.pojo.WhDetailed;
import com.fs.pojo.WhInvInventory;
import com.fs.pojo.WhWarehousing;
import com.fs.service.WhDetailedService;
import com.fs.vo.Condition;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class WhDetailedServiceImpl implements WhDetailedService {
    @Resource
    WhDetailedMapper mapper;

    @Override
    public Page<WhDetailed> selectDatail(Condition<WhWarehousing> condition) {
        Page<WhDetailed> page = new Page<>(condition.getPage(), condition.getCount());
        LambdaQueryWrapper<WhDetailed> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(condition.getSearch().getWarehousingEntryId() != null, WhDetailed::getWarehousingId, condition.getSearch().getWarehousingEntryId());

        mapper.selectPage(page, wrapper);
        return page;
    }



    @Override
    public void deleteDatail(int detailedId) {

    }

    /**
     * 根据出库id查询明细分页查询
     * @param condition 库存对象
     * @return 对象列表
     */
    @Override
    public PageInfo<WhDetailed> selectWD(Condition<WhDetailed> condition) {
        PageHelper.startPage(condition.getPage(), condition.getCount());
        List<WhDetailed> whInvInventories = mapper.selectWD(condition.getSearch());
        return new PageInfo<>(whInvInventories);
    }
//    @Override
//    public List<WhDetailed> selectDatail(int warehousingEntryId) {
//        QueryWrapper<WhDetailed> wrapper = new QueryWrapper<>();
//        System.out.println(warehousingEntryId);
//        wrapper.eq("warehousing_id", warehousingEntryId); // 假设数据库中的列名为warehousing_entry_id
//        return mapper.selectList(wrapper);
//    }
}
